export const event = {
  /**
   * on
   */
  on(eventType, callback) {
    if (eventType in this.handlers) {
      this.handlers[eventType].add(callback);
    } else {
      const set = new Set();
      set.add(callback);
      this.handlers[eventType] = set;
    }
  },

  dispatch(eventType, payload) {
    const handlers = this.handlers[eventType] || [];
    handlers.forEach((hand) => {
      hand(payload);
    });
  },
};
